package com.qf.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
@Configuration
public class MyESConfig extends AbstractElasticsearchConfiguration {
    @Override
    @Bean
    public RestHighLevelClient elasticsearchClient() {
//          获取地址
        HttpHost httpHost = new HttpHost("10.9.45.217", 9200, "http");
//      构造连接
        RestClientBuilder builder = RestClient.builder(httpHost);


        RestHighLevelClient restHighLevelClient=new RestHighLevelClient(builder);

        return restHighLevelClient;
    }
}
